var fs = require("fs");
var weatherStr = fs.readFileSync("./weather.json", "utf-8");
var weather = JSON.parse(weatherStr);

var wr = weather.results[0];

var ww=wr.weather_data

var messtr=``
for(var i = 1; i <ww.length ; i++){
    messtr +=`
    <div>
        <p class="weekend">${wr.weather_data[i].date}</p>
        <img src="${wr.weather_data[i].dayPictureUrl}" alt="">
        <p>${wr.weather_data[i].temperature}</p>
        <p>${wr.weather_data[i].weather}</p>
        <p>${wr.weather_data[i].wind}</p>
    </div>
    `
    
}

var htmlStr = `
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <meta name="author" content="林镭特">
    <link rel="stylesheet" href="weather.css">
    <title></title>
    <style>
        
    </style>
</head>
<body>

<main>
<h3>${weather.results[0].currentCity}</h3>

<div class="today">
    <img src="http://api.map.baidu.com/images/weather/night/duoyun.png" alt="">
    <div class="wendu">${wr.weather_data[0].temperature}</div>
    <p class="tianqi">${wr.weather_data[0].weather}</p>
    <p class="fengxiang">${wr.weather_data[0].wind}</p>
    <p class="shishi">实时温度：16°C，空气指数${wr.pm25}</p>
</div>

<div class="mingtian">
    ${messtr}
</div>
</main>
   
</body>
</html>
   
`;

fs.writeFileSync("index.html", htmlStr);
